home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10500 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  51 lines

  1. Path: gwen.pcug.co.uk!altheim!broldham
  2. Newsgroups: comp.lang.c
  3. Message-ID: <1239@altheim.win-uk.net>
  4. Reply-To: broldham@altheim.win-uk.net (Brian R. Oldham)
  5. From: broldham@altheim.win-uk.net (Brian R. Oldham)
  6. Date: Mon, 18 Mar 1996 08:47:26 GMT
  7. Subject: Pointers to register
  8.  
  9. A couple of weeks ago someone posted the opinion that all objects in
  10. memory must have an address, which might have gone uncontested but for
  11. the fact that he added that therefore all pointers must point to an
  12. address. Someone else reminded us that registers don't have an address.
  13.  
  14. Bearing in mind the usual way to assign a pointer:
  15.  
  16.     ptr = &var;
  17.  
  18. is correct for objects in memory, but how do you assign a pointer
  19. to a register? 
  20.  
  21. The following function (a getch() for x86) works: But is it right??
  22.     
  23. /* Read next keystroke */
  24. #include <dos.h>
  25.  
  26. #define KEYBD 0x16
  27.  
  28. static union REGS inregs, outregs;
  29.  
  30. void getkey(int *scancode, char *ch) 
  31. {
  32.     inregs.h.ah = 0x00;
  33.     int86(KEYBD,&inregs,&outregs);
  34.     *scancode = outregs.h.ah;     /* ??? */
  35.     *ch = outregs.h.al;             
  36. }
  37.  
  38.  
  39. ---
  40. Brian Oldham
  41. Hucknall UK
  42. !...Gesundbrunnen
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.